﻿
SET QUOTED_IDENTIFIER ON
GO

SET ANSI_NULLS ON
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_Staff_SetIsNeedKey]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_Staff_SetIsNeedKey];
GO
CREATE PROCEDURE [dbo].[sproc_Staff_SetIsNeedKey]
    @xml xml,
    @IsNeedKey bit
AS
BEGIN
SET NOCOUNT ON

/*
 * XML format:
 * <staffs>
 *  <s id="" />
 * </staffs>
 */

update s
set s.isneedkey = @IsNeedKey
from dbo.UDS_Staff s inner join @xml.nodes('/staffs/s') R(x) on s.staff_id = R.x.value('@id', 'int');

RETURN 0;

END
GO